package com.bawei.rk_01.Adapter

import android.graphics.Color
import android.widget.TextView
import com.bawei.base.utils.bean.ExplosiveMoney
import com.bawei.rk_01.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import kotlin.reflect.jvm.internal.impl.incremental.components.Position

class MoneyAdapter : BaseQuickAdapter<ExplosiveMoney,BaseViewHolder>(R.layout.item_money) {

    var setindex = 4

    override fun convert(holder: BaseViewHolder, item: ExplosiveMoney) {
        holder.setText(R.id.money_name,item.name)
        holder.setText(R.id.money_info,item.info)

        if (setindex == item.type.toInt()){
            //选中状态
            holder.getView<TextView>(R.id.money_name).setTextColor(Color.RED)
            holder.getView<TextView>(R.id.money_name).setBackgroundResource(R.drawable.bg_money)
        }else{
            holder.getView<TextView>(R.id.money_name).setTextColor(Color.BLACK)
            holder.getView<TextView>(R.id.money_name).background = null
        }

    }

    fun setIndex(position:Int){
        setindex = position
        notifyDataSetChanged()
    }

}